CREATE TABLE [agency].[Address]
(
[AddressId] [int] NOT NULL IDENTITY(1, 1),
[AddressTypeId] [int] NOT NULL,
[CompanyId] [int] NOT NULL,
[AddressLine1] [nvarchar] (250) COLLATE SQL_Latin1_General_CP1_CI_AS NOT NULL,
[AddressLine2] [nvarchar] (250) COLLATE SQL_Latin1_General_CP1_CI_AS NOT NULL,
[LandMark] [nvarchar] (250) COLLATE SQL_Latin1_General_CP1_CI_AS NOT NULL,
[CityId] [int] NOT NULL,
[StateId] [int] NOT NULL,
[CountryId] [int] NOT NULL,
[Active] [bit] NOT NULL,
[Deleted] [bit] NOT NULL,
[CreatedBy] [int] NOT NULL,
[CreatedOn] [datetime] NOT NULL,
[ModifiedBy] [int] NULL,
[ModifiedOn] [datetime] NULL
) ON [PRIMARY]
GO
ALTER TABLE [agency].[Address] ADD CONSTRAINT [PK_Address] PRIMARY KEY CLUSTERED  ([AddressId]) ON [PRIMARY]
GO
ALTER TABLE [agency].[Address] ADD CONSTRAINT [FK_Address_AddressType] FOREIGN KEY ([AddressTypeId]) REFERENCES [agency].[AddressType] ([AddressTypeId])
GO
ALTER TABLE [agency].[Address] ADD CONSTRAINT [FK_Address_City] FOREIGN KEY ([CityId]) REFERENCES [agency].[City] ([CityId])
GO
ALTER TABLE [agency].[Address] ADD CONSTRAINT [FK_Address_Company] FOREIGN KEY ([CompanyId]) REFERENCES [agency].[Company] ([CompanyId])
GO
ALTER TABLE [agency].[Address] ADD CONSTRAINT [FK_Address_Country] FOREIGN KEY ([CountryId]) REFERENCES [agency].[Country] ([CountryId])
GO
ALTER TABLE [agency].[Address] ADD CONSTRAINT [FK_Address_State] FOREIGN KEY ([StateId]) REFERENCES [agency].[State] ([StateId])
GO
